package models

import (
	"time"

	"github.com/astaxie/beego/orm"
	"github.com/pkg/errors"
)

type IpccConfigAsrServ struct {
	Id        int
	Brand     string
	ServAddr  string
	Port      int
	Active    bool
	CreatTime time.Time
}

func GetAllAsrServs() ([]IpccConfigAsrServ, error) {

	var result []IpccConfigAsrServ

	o := orm.NewOrm()
	o.Using("default")

	num, err := o.QueryTable("IpccConfigAsrServ").Filter("Active", true).All(&result)
	if err != nil {
		return nil, err
	}

	if 0 == num {
		return nil, errors.New("no keys")
	}

	return result, nil
}

func RegConfAsrServ() {
	orm.RegisterModel(new(IpccConfigAsrServ))
}
